﻿Imports System.Collections
Imports Microsoft.Win32

Module Globales

    Public arrayItemTransaccion As ArrayList = New ArrayList
    Public arrayItemNC As ArrayList = New ArrayList

    Public tasaSC As Double
    Public terminalEwave As String
    Public usuario As String


    Public Sub setTasaSC()

        'Cambiar por la tasa que se obtiene de la bd
        tasaSC = 15

    End Sub

    Public Function getTasaSC() As Double

        Return tasaSC

    End Function

    Public Function getArrayItems() As ArrayList

        Return arrayItemTransaccion

    End Function

    'array iten nc
    Public Function getArrayItemsNC() As ArrayList

        Return arrayItemNC

    End Function

    Public Sub vaciarArrayItemNC()

        arrayItemNC.Clear()

    End Sub

    Public Sub vaciarArrayItemTransaccion()

        arrayItemTransaccion.Clear()

    End Sub

    Public Function getEspectaculo() As String

        Dim deta As DetalleTransaccion
        Dim tr As String = ""

        For Each deta In arrayItemTransaccion

            tr = deta.idTransaccion
            Exit For
        Next

        Return tr

    End Function

    Public Function getImporteTotalEntradas() As Double

        Dim it As DetalleTransaccion
        Dim totalEntradas As Double

        For Each it In Globales.arrayItemTransaccion

            totalEntradas += it.montoTotal

        Next

        Return totalEntradas

    End Function

    Public Function calcularSC() As Double

        Dim importeSC As Double

        importeSC = FormatNumber((getImporteTotalEntradas() * getTasaSC() / 100), 2)
       
        Return importeSC

    End Function

    Public Sub setTerminalEwave()

        terminalEwave = obtenerTerminalEwave()

    End Sub

    
    Public Function obtenerTerminalEwave() As String

        'WINDOWS 7
        Dim valorWin7 = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Wow6432Node\ewave", "TerminalId", Nothing)

        If Not IsNothing(valorWin7) Then
            'MsgBox("Valor del registro en windows 7: " & valorWin7.ToString)
            Return valorWin7
        Else
            'WINDOWS XP
            Dim valorWinXP = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\ewave", "TerminalId", Nothing)
            If Not IsNothing(valorWinXP) Then
                'MsgBox("Valor del registro en windows xp: " & valorWinXP.ToString)
                Return valorWinXP
            Else
                Return "9999"
            End If
        End If

    End Function

    Public Sub setUsuarioActivo(ByVal u As String)

        usuario = u

    End Sub

    Public Function getUsuarioActivo() As String

        Return usuario

    End Function

End Module
